USE [RLZY]
GO
/****** Object:  StoredProcedure [dbo].[pro_SQB_Unit5]    Script Date: 08/01/2014 21:44:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



ALTER proc [dbo].[pro_SQB_Unit5](@lastdate varchar(20),@thisdate varchar(20),@bm varchar(20))
as
declare   @VarX2 int,@VarX3 int, @VarX4 int, @VarX5 int,  @VarX6 Decimal(18,1),@VarX7 int,  @VarX8 int,   @VarX9 int,  @VarX10 int,  @VarX11 int,  @VarX12 Decimal(18,1), @VarX13 Decimal(18,1),@VarX14 Decimal(18,2),  @VarX15 Decimal(18,1),@VarX16 Decimal(18,1),@VarX17 Decimal(18,2),  @VarX18  Decimal(18,2)   
declare  @VarXS2 int,@VarXS3 int, @VarXS4 int, @VarXS5 int,  @VarXS6 Decimal(18,1),@VarXS7 int,  @VarXS8 int,   @VarXS9 int,  @VarXS10 int,  @VarXS11 int,  @VarXS12 Decimal(18,1), @VarXS13 Decimal(18,1),@VarXS14 Decimal(18,2),  @VarXS15 Decimal(18,1),@VarXS16 Decimal(18,1),@VarXS17 Decimal(18,2),  @VarXS18  Decimal(18,2)   
select  @VarX2=Sum(人数) ,@VarX3=Sum(技能工资) ,@VarX4=Sum(岗位工资)  ,@VarX5=Sum(绩效工资),@VarX6=Sum(三项补贴),@VarX7=Sum(回贴),@VarX8=Sum(工龄津贴),@VarX9=Sum(职称津贴),@VarX10=Sum(特岗津贴),@VarX11=Sum(卫生纸费),@VarX12=Sum(中晚班费),@VarX13=Sum(加班工资),@VarX14=Sum(补发),@VarX15=Sum(扣事假工资),@VarX16=Sum(扣病假工资),@VarX17=Sum(其它扣款),@VarX18=Sum(应发总额) from GZ61 where  (用工性质 like '%固%' or 用工性质 like '%制%' or 用工性质 like '%合%') and  not (用工性质 like  '%上月%') 
select   @VarXS2=Sum(人数) ,@VarXS3=Sum(技能工资) ,@VarXS4=Sum(岗位工资)  ,@VarXS5=Sum(绩效工资),@VarXS6=Sum(三项补贴),@VarXS7=Sum(回贴),@VarXS8=Sum(工龄津贴),@VarXS9=Sum(职称津贴),@VarXS10=Sum(特岗津贴),@VarXS11=Sum(卫生纸费),@VarXS12=Sum(中晚班费),@VarXS13=Sum(加班工资),@VarXS14=Sum(补发),@VarXS15=Sum(扣事假工资),@VarXS16=Sum(扣病假工资),@VarXS17=Sum(其它扣款),@VarXS18=Sum(应发总额) from GZ61 where  (用工性质 like '%固%' or 用工性质 like '%制%' or 用工性质 like '%合%') and   用工性质 like  '%上月%' 
insert into GZ_SQB(用工性质,[人数],  [技能工资], [岗位工资], [绩效工资], [三项补贴], [回贴], [工龄津贴], [职称津贴], [特岗津贴], [卫生纸费], [中晚班费], [加班工资], [补发], [扣事假工资],  [扣病假工资],[其它扣款],[应发总额]) values ('差异--合计', @VarX2-@VarXS2,@VarX3-@VarXs3,@VarX4-@VarXs4,@VarX5-@VarXs5,@VarX6-@VarXs6,@VarX7-@VarXs7,@VarX8-@VarXs8,@VarX9-@VarXs9,@VarX10-@VarXs10,@VarX11-@VarXs11,@VarX12-@VarXs12,@VarX13-@VarXs13,@VarX14-@VarXs14,@VarX15-@VarXs15,@VarX16-@VarXs16,@VarX17-@VarXs17,@VarX18-@VarXs18)
select  @VarX2=Sum(人数) ,@VarX3=Sum(技能工资) ,@VarX4=Sum(岗位工资)  ,@VarX5=Sum(绩效工资),@VarX6=Sum(三项补贴),@VarX7=Sum(回贴),@VarX8=Sum(工龄津贴),@VarX9=Sum(职称津贴),@VarX10=Sum(特岗津贴),@VarX11=Sum(卫生纸费),@VarX12=Sum(中晚班费),@VarX13=Sum(加班工资),@VarX14=Sum(补发),@VarX15=Sum(扣事假工资),@VarX16=Sum(扣病假工资),@VarX17=Sum(其它扣款),@VarX18=Sum(应发总额) from GZ61 where  (用工性质 like '%固%' ) and  not (用工性质 like  '%上月%')  
select  @VarXS2=Sum(人数) ,@VarXS3=Sum(技能工资) ,@VarXS4=Sum(岗位工资)  ,@VarXS5=Sum(绩效工资),@VarXS6=Sum(三项补贴),@VarXS7=Sum(回贴),@VarXS8=Sum(工龄津贴),@VarXS9=Sum(职称津贴),@VarXS10=Sum(特岗津贴),@VarXS11=Sum(卫生纸费),@VarXS12=Sum(中晚班费),@VarXS13=Sum(加班工资),@VarXS14=Sum(补发),@VarXS15=Sum(扣事假工资),@VarXS16=Sum(扣病假工资),@VarXS17=Sum(其它扣款),@VarXS18=Sum(应发总额)  from GZ61 where  (用工性质 like '%固%' ) and   用工性质 like  '%上月%'  
insert into GZ_SQB(用工性质,[人数],  [技能工资], [岗位工资], [绩效工资], [三项补贴], [回贴], [工龄津贴], [职称津贴], [特岗津贴], [卫生纸费], [中晚班费], [加班工资], [补发], [扣事假工资],  [扣病假工资],[其它扣款],[应发总额]) values ('差异--固',@VarX2-@VarXS2,@VarX3-@VarXS3,@VarX4-@VarXS4,@VarX5-@VarXS5,@VarX6-@VarXS6,@VarX7-@VarXS7,@VarX8-@VarXS8,@VarX9-@VarXS9,@VarX10-@VarXS10,@VarX11-@VarXS11,@VarX12-@VarXS12,@VarX13-@VarXS13,@VarX14-@VarXS14,@VarX15-@VarXS15,@VarX16-@VarXS16,@VarX17-@VarXS17,@VarX18-@VarXS18)  
select  @VarX2=Sum(人数) ,@VarX3=Sum(技能工资) ,@VarX4=Sum(岗位工资)  ,@VarX5=Sum(绩效工资),@VarX6=Sum(三项补贴),@VarX7=Sum(回贴),@VarX8=Sum(工龄津贴),@VarX9=Sum(职称津贴),@VarX10=Sum(特岗津贴),@VarX11=Sum(卫生纸费),@VarX12=Sum(中晚班费),@VarX13=Sum(加班工资),@VarX14=Sum(补发),@VarX15=Sum(扣事假工资),@VarX16=Sum(扣病假工资),@VarX17=Sum(其它扣款),@VarX18=Sum(应发总额)  from GZ61 where  (用工性质 like '%制%' ) and  not (用工性质 like  '%上月%')  
select  @VarXS2=Sum(人数) ,@VarXS3=Sum(技能工资) ,@VarXS4=Sum(岗位工资)  ,@VarXS5=Sum(绩效工资),@VarXS6=Sum(三项补贴),@VarXS7=Sum(回贴),@VarXS8=Sum(工龄津贴),@VarXS9=Sum(职称津贴),@VarXS10=Sum(特岗津贴),@VarXS11=Sum(卫生纸费),@VarXS12=Sum(中晚班费),@VarXS13=Sum(加班工资),@VarXS14=Sum(补发),@VarXS15=Sum(扣事假工资),@VarXS16=Sum(扣病假工资),@VarXS17=Sum(其它扣款),@VarXS18=Sum(应发总额)  from GZ61 where  (用工性质 like '%制%' ) and   用工性质 like  '%上月%'  
insert into GZ_SQB(用工性质,[人数],  [技能工资], [岗位工资], [绩效工资], [三项补贴], [回贴], [工龄津贴], [职称津贴], [特岗津贴], [卫生纸费], [中晚班费], [加班工资], [补发], [扣事假工资],  [扣病假工资],[其它扣款],[应发总额]) values ('差异--制',@VarX2-@VarXS2,@VarX3-@VarXs3,@VarX4-@VarXs4,@VarX5-@VarXs5,@VarX6-@VarXs6,@VarX7-@VarXs7,@VarX8-@VarXs8,@VarX9-@VarXs9,@VarX10-@VarXs10,@VarX11-@VarXs11,@VarX12-@VarXs12,@VarX13-@VarXs13,@VarX14-@VarXs14,@VarX15-@VarXs15,@VarX16-@VarXs16,@VarX17-@VarXs17,@VarX18-@VarXs18) 
select  @VarX2=Sum(人数) ,@VarX3=Sum(技能工资) ,@VarX4=Sum(岗位工资)  ,@VarX5=Sum(绩效工资),@VarX6=Sum(三项补贴),@VarX7=Sum(回贴),@VarX8=Sum(工龄津贴),@VarX9=Sum(职称津贴),@VarX10=Sum(特岗津贴),@VarX11=Sum(卫生纸费),@VarX12=Sum(中晚班费),@VarX13=Sum(加班工资),@VarX14=Sum(补发),@VarX15=Sum(扣事假工资),@VarX16=Sum(扣病假工资),@VarX17=Sum(其它扣款),@VarX18=Sum(应发总额) from GZ61 where  (用工性质 like '%合%' ) and  not (用工性质 like  '%上月%') 
select  @VarXS2=Sum(人数) ,@VarXS3=Sum(技能工资) ,@VarXS4=Sum(岗位工资)  ,@VarXS5=Sum(绩效工资),@VarXS6=Sum(三项补贴),@VarXS7=Sum(回贴),@VarXS8=Sum(工龄津贴),@VarXS9=Sum(职称津贴),@VarXS10=Sum(特岗津贴),@VarXS11=Sum(卫生纸费),@VarXS12=Sum(中晚班费),@VarXS13=Sum(加班工资),@VarXS14=Sum(补发),@VarXS15=Sum(扣事假工资),@VarXS16=Sum(扣病假工资),@VarXS17=Sum(其它扣款),@VarXS18=Sum(应发总额)  from GZ61 where  (用工性质 like '%合%' ) and   用工性质 like  '%上月%'  
insert into GZ_SQB(用工性质,[人数],  [技能工资], [岗位工资], [绩效工资], [三项补贴], [回贴], [工龄津贴], [职称津贴], [特岗津贴], [卫生纸费], [中晚班费], [加班工资], [补发], [扣事假工资],  [扣病假工资],[其它扣款],[应发总额]) values ('差异--合',@VarX2-@VarXS2,@VarX3-@VarXs3,@VarX4-@VarXs4,@VarX5-@VarXs5,@VarX6-@VarXs6,@VarX7-@VarXs7,@VarX8-@VarXs8,@VarX9-@VarXs9,@VarX10-@VarXs10,@VarX11-@VarXs11,@VarX12-@VarXs12,@VarX13-@VarXs13,@VarX14-@VarXs14,@VarX15-@VarXs15,@VarX16-@VarXs16,@VarX17-@VarXs17,@VarX18-@VarXs18) 
GO